<template>
  <BasicModal v-bind="$attrs" @register="addModal" width="50%" height="80%" @cancel='handCancel'>
    <div style="padding: 40px 20px 0 20px">
      <DepartRoleInfoTab :isShow="isShow" :isAdd="isAdd" :productId="orderMainModel.productId" />
    </div>
  </BasicModal>
</template>

<script lang="ts" setup>
  import { ref, computed, unref, reactive } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { formSchema } from '../ProductCategory.data';
  import { saveOrUpdate } from '../ProductCategory.api';
  import DepartRoleInfoTab from '../../device/ModelInfoList.vue';
  import { getModelList} from '../../device/ModelInfo.api';
  const form = {}
  const productId = ref<number>(0);
  // Emits声明
  const emit = defineEmits(['register', 'success']);
  const isUpdate = ref(true);

  // form表单 col
  const labelCol = { span: 4 };
  const wrapperCol = { span: 20 };

  const orderMainModel = reactive({
    id: null,
    productName: '',
  });
  const isShow = true;
  const isAdd = true;
  const [addModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
    setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
    isUpdate.value = !!data?.isUpdate;
    if (unref(isUpdate)) {
      console.log('==================================================')
      // rowId.value = data.record.id;
      Object.assign(orderMainModel, data.record);
    }
   
  })

  async function handleSubmit(v) {
    // try {
    //   let values = await validate();
    //   setModalProps({ confirmLoading: true });
    //   //提交表单
    //   await saveOrUpdate(values, isUpdate.value);
    //   //关闭弹窗
    //   closeModal();
    //   //刷新列表
    //   emit('success', { isUpdate: isUpdate.value, values });
    // } finally {
    //   setModalProps({ confirmLoading: false });
    // }
  }
  async function handCancel(v) {
   Object.assign(isAdd, false);
  }
</script>

<style lang="less">
</style>
